import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class UserModel {
  final String jobNumber;
  final String name;
  final String mobile;
  final String avatar;
  final String department;

  UserModel({
    required this.jobNumber,
    required this.name,
    required this.mobile,
    this.avatar = '',
    required this.department,
  });

  factory UserModel.fromJson(Map<String, dynamic> json) {
    return UserModel(
      jobNumber: json['jobNumber'] ?? '',
      name: json['name'] ?? '',
      mobile: json['mobile'] ?? '',
      avatar: json['avatar'] ?? '',
      department: json['roleType'] ==0?'司机':'检查人'
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'jobNumber': jobNumber,
      'name': name,
      'mobile': mobile,
      'avatar': avatar,
      'department': department
    };
  }
}